package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

/**
 * @description: 模板中心：应用模板分类
 * @Author: hongxiao
 * @date: 2019-03-02 20:54
 * @since v1.0
 */
@Getter
public enum AppModuleTypeEnum {
    /**
     * 应用模板分类
     */
    OFFICIAL_MODULE(1, "enum.appModuleType.name.official_module"),


    THIRD_PART_MODULE(2, "enum.appModuleType.name.third_part_module"),


    UNKNOWN(404, "enum.appModuleType.name.unknown"),
    ;

    /**
     * 应用模板类型
     */
    private int code;
    /**
     * 应用模板类型名称
     */
    private String name;

    AppModuleTypeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }
    public static AppModuleTypeEnum getByCode(Integer code) {
        if(code == null) {
            return UNKNOWN;
        }
        for (AppModuleTypeEnum cacheCode : values()) {
            if (code.equals(cacheCode.getCode())) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
